package com.example.springboot_study.dao.primary;

import com.example.springboot_study.entity.primary.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author : liqun
 * @createTime : 2021/9/14 9:45
 */
@Mapper
public interface UserMapper {
    /*@Results({
            @Result(property = "name",column = "name"),
            @Result(property = "age",column = "age")
    })*/
    //@Select("select name,age from user")
    List<User> findAll();

    List<User> findByName(@Param("name") String name);

    //@Select("SELECT name,age FROM USER WHERE NAME = #{name}")
    //@Insert("INSERT INTO USER(NAME, AGE) VALUES(#{name}, #{age})")
    int insert(@Param("name") String name, @Param("age") Integer age);

    //@Update("UPDATE user SET age=#{age} WHERE name=#{name}")
    int update(User user);

    //@Delete("DELETE FROM user WHERE name =#{name}")
    int deleteByName(String name);

    //@Delete("DELETE FROM user")
    int deleteAll();
}
